from typing import List


class Solution:
    """
    我自己的方法 太垃圾了 就击败5%  还得练
    """
    def groupAnagrams(self, strs: List[str]) -> List[List[str]]:
        res = []
        resList = strs.copy()
        ress = [[] for i in range(len(resList))]
        ress2 = [[] for i in range(len(resList))]
        for i in range(len(resList)):
            resList[i] = ''.join(sorted(list(resList[i])))
        flag = 0
        for j in range(len(resList)):
            found = False
            if len(ress[flag]) == 0:
                ress[flag].append(resList[j])
                ress2[flag].append(j)
                continue
            for k in range(len(resList)):
                if resList[j] in ress[k]:
                    ress[k].append(resList[j])
                    ress2[k].append(j)
                    found = True
                    break
            if found == False:
                flag += 1
                ress[flag].append(resList[j])
                ress2[flag].append(j)
        for i in range(len(ress2)):
            if (len(ress2[i]) == 0):
                continue
            list1 = []
            for j in range(len(ress2[i])):
                list1.append(strs[ress2[i][j]])
            res.append(list1)
        return res


    def groupAnagrams2(self, strs: List[str])->List[List[str]]:
        """
        尝试使用哈希表
        :param strs:
        :return:
        """
        return [[]]


lll = Solution()
print(lll.groupAnagrams(["eat", "tea", "tan", "ate", "nat", "bat"]))

"""
输入: strs = ["eat", "tea", "tan", "ate", "nat", "bat"]
输出: [["bat"],["nat","tan"],["ate","eat","tea"]]
"""
